import { createRouter, createWebHistory } from "vue-router";
// import store from "../store";

const routes = [
  /**
   * * 导航主页模块
  */
  {
    path: "/",
    component: async () => await import("@/views/appPage/index.vue")
  },
  {
    path: "/serachList",
    component: async () => await import("@/views/appPage/serachList.vue")
  },
  {
    path: "/search",
    component: async () => await import("@/views/appPage/search.vue")
  },
  {
    path: "/payCard",
    component: async () => await import("@/views/appPage/payCard.vue")
  },
  {
    path: "/myInfo",
    component: async () => await import("@/views/appPage/myInfo.vue")
  },
  /**
   * * 二级页面
  */
  // 订单确认

  // 个人设置

  // 个人资料编辑

  // 我的订单列表

  // 订单详情

  // 我的收藏

  // 专题列表

  // 专题详情
  
  // 商品详情
  {
    path: "/product/detail",
    component: async () => await import("@/views/appPage/product/detail.vue")
  },

  /**
   * * 管理后台
  */
  {
    path: "/admin",
    component: async () => await import("@/views/adminPage/index.vue")
  },

  {
    path: "/admin/login",
    component: async () => await import("@/views/adminPage/login.vue")
  },

];

const router = createRouter({
  history: createWebHistory(),
  routes
});

// 路由守卫
router.beforeEach((to, from, next) => {
  next();
  // if (
  //   store.getters.authorization || 
  //   ["/login", "/SignUp", "/loading"].includes(to.path)
  // ) {
  //   next();
  // } else {
  //   next("/login");
  // }
});

export default router;
